<?php
$title = '账户';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<hr>
<h3><?php echo $this->escapeHtml('支票' . $title); ?></h3>
<hr>
<table class="table table-hover table-striped">
    <tr>
        <th>账户号</th>
        <th>银行</th>
        <th>支出</th>
        <th>利率</th>
        <th>利润</th>
        <th>透支额</th>
        <th>余额</th>
        <th>贷款</th>
    </tr>
    <?php foreach ($this->check as $key => $check) { ?>
        <tr>
            <td><?php echo $check['account_id']; ?></td>
            <td><?php echo $check['bank_name']; ?></td>
            <td><?php echo $check['account_balance']; ?></td>
            <td><?php echo $check['rate'] * 100; ?>%</td>
            <td><?php echo $check['account_balance'] * $check['rate']; ?></td>
            <td><?php echo $check['overdraft']; ?></td>
            <td><?php echo $check['overdraft'] - $check['account_balance']; ?></td>
            <td>
                <a href="<?php echo $this->url("account/default", array("controller" => "loan", "action" => "index", "id" => $check['account_id'])); ?>">查看</a>
            </td>
        </tr>
    <?php } ?>
    <tr>
        <th>合计</th>
        <td></td>
        <td><?php echo $this->payment; ?></td>
        <td></td>
        <td><?php echo $this->check_profit; ?></td>
        <td></td>
        <td><?php echo $this->check_balance; ?></td>
        <td></td>
    </tr>
</table><br>
<h3><?php echo $this->escapeHtml('储蓄' . $title); ?></h3>
<hr>
<table class="table table-hover table-striped">
    <tr>
        <th>账户号</th>
        <th>银行</th>
        <th>利率</th>
        <th>利润</th>
        <th>余额</th>
        <th>存取</th>
    </tr>
    <?php foreach ($this->thrift as $key => $thrift) { ?>
        <tr>
            <td><?php echo $thrift['account_id']; ?></td>
            <td><?php echo $thrift['bank_name']; ?></td>
            <td><?php echo $thrift['rate'] * 100; ?>%</td>
            <td><?php echo $thrift['account_balance'] * $thrift['rate']; ?></td>
            <td><?php echo $thrift['account_balance']; ?></td>
            <td>
                <a href="<?php echo $this->url("account/default", array("controller" => "access", "action" => "index", "id" => $thrift['account_id'])); ?>">查看</a>
            </td>
        </tr>
    <?php } ?>
    <tr>
        <th>合计</th>
        <td></td>
        <td></td>
        <td><?php echo $this->thrift_profit; ?></td>
        <td><?php echo $this->thrift_balance; ?></td>
        <td></td>
    </tr>
</table><br>
<h3><?php echo $this->escapeHtml('所有' . $title); ?></h3>
<hr>
<table class="table table-hover table-striped">
    <tr>
        <th>账户号</th>
        <th>银行</th>
        <th>支出</th>
        <th>透支额</th>
        <th>利率</th>
        <th>利润</th>
        <th>余额</th>
        <th>类型</th>
    </tr>
    <?php foreach ($this->account as $key => $account) { ?>
        <tr>
            <td><?php echo $account['account_id']; ?></td>
            <td><?php echo $account['bank_name']; ?></td>
            <td><?php echo is_null($account['overdraft']) ? null : $account['account_balance']; ?></td>
            <td><?php echo is_null($account['overdraft']) ? null : $account['overdraft']; ?></td>
            <td><?php echo $account['rate'] * 100; ?>%</td>
            <td><?php echo $account['account_balance'] * $account['rate']; ?></td>
            <td><?php echo is_null($account['overdraft']) ? $account['account_balance'] : $account['overdraft'] - $account['account_balance']; ?></td>
            <td><?php echo is_null($account['overdraft']) ? '储蓄账户' : '支票账户'; ?></td>
        </tr>
    <?php } ?>
    <tr>
        <th>合计</th>
        <td></td>
        <td><?php echo $this->payment; ?></td>
        <td></td>
        <td></td>
        <td><?php echo $this->account_profit; ?></td>
        <td><?php echo $this->account_balance; ?></td>
        <td></td>
    </tr>
</table>